package www.com.springboot_20200312.rabbitmqDemo.batchSendMessage.producer;

import org.springframework.amqp.rabbit.core.BatchingRabbitTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture;
import www.com.springboot_20200312.rabbitmqDemo.batchSendMessage.message.DemoBatchMessage;

/**
 * @program: springboot_20200312
 * @ClassName Demo01Producer
 * @description:
 * @author: jht
 * @create: 2021-12-07 10:25
 * @Version 1.0
 **/
@Component
public class DemoBatchProducer {
    @Autowired
    private BatchingRabbitTemplate batchingRabbitTemplate;

    public void syncSend(Integer id) {
        // 创建 Demo05Message 消息
        DemoBatchMessage message = new DemoBatchMessage();
        message.setId(id);
        // 同步发送消息
        batchingRabbitTemplate.convertAndSend(DemoBatchMessage.EXCHANGE, DemoBatchMessage.ROUTING_KEY, message);
    }
}
